// This is the class functions to get the text from the ueser and place it 
// into a vector for use by the converter class.
// Copyright (C) 2008  Nicholas Hinkley <DarkLight.Programmer@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

// To output/input 
#include <iostream>

// To use the vector
#include <vector>
// To keep the code somewhat clean, somewhat.
using namespace std;

// The class deff for this file.
#include "inputtxt.h"

InputTxt::InputTxt() {

}

InputTxt::~InputTxt(){

}

// get the text from the user.    
int InputTxt::gettxt() {
   char inchar; // Temp char to hold a char for a shart time.

   // Tell the user what to do
   cout << "\n\n"
        << "Please enter text to convert to Morse code now.\n [New line to stop]\n: ";
        
   // Get the first char from the user.     
   inchar = cin.get();
   
   // Start to get more chars.
   while( inchar != '\n') {
      
      input.push_back(inchar);
      inchar = cin.get();
      
   }
   
   input.push_back(EOF);
      
   // tell them that it is done.
   cout << "\n";
        // do need this but leave it here for testing << "Text has be enterd.\n";
       

}

vector<char> InputTxt::sendtxt() {

   return input;

}


// show the text to the user so they can see that they entered the text right.
int InputTxt::test() {
   
   cout << "\nOutputing as text:\n";
   
   int end = 0;
   //end = input.end();
   char out;
   // Start at the begining of the vector and print the char until the end.
   for(int i = 0; input[i] != EOF ; i++) { // Setup the counter test and increment all in one.
      
      switch(input[i]) { 
         case '\b': break; // test of backspace and ignore it
            
         case '\t': break; // test for tab and ignore it.
         default: // what to do for any thing else
               cout << input[i];
            
      }
      
   }
   
   
   // dont need this leave for testing cout << "\nEnd Test, text should have displayed.\n\n";
}

// End of file [with a new line at the end to make some compilers happy]
